﻿<div style="color:Black;background-color:White;"><pre>
<span style="color:Blue;">USE</span> AdventureWorks;
GO
<span style="color:Blue;">SELECT</span> <span style="color:Magenta;">MIN</span>(TaxRate)
<span style="color:Blue;">FROM</span> Sales.SalesTaxRate;
GO

<span style="color:Blue;">USE</span> AdventureWorks;
GO
<span style="color:Blue;">SELECT</span> <span style="color:Magenta;">MAX</span>(TaxRate)
<span style="color:Blue;">FROM</span> Sales.SalesTaxRate;
GO

<span style="color:Green;">--Get the checksum value before the column value is changed.</span>
<span style="color:Blue;">USE</span> AdventureWorks;
GO
<span style="color:Blue;">SELECT</span> <span style="color:Magenta;">CHECKSUM</span>(<span style="color:Magenta;">CAST</span>(Quantity <span style="color:Blue;">AS</span> <span style="color:Blue;">int</span>))
<span style="color:Blue;">FROM</span> Production.ProductInventory;
GO

<span style="color:Blue;">UPDATE</span> Production.ProductInventory 
<span style="color:Blue;">SET</span> Quantity=125
<span style="color:Blue;">WHERE</span> Quantity=100;
GO
<span style="color:Green;">--Get the checksum of the modified column.</span>
<span style="color:Blue;">SELECT</span> <span style="color:Magenta;">CHECKSUM</span>(<span style="color:Magenta;">CAST</span>(Quantity <span style="color:Blue;">AS</span> <span style="color:Blue;">int</span>))
<span style="color:Blue;">FROM</span> Production.ProductInventory;

<span style="color:Blue;">USE</span> AdventureWorks;
GO
<span style="color:Blue;">SELECT</span> <span style="color:Magenta;">COUNT</span>(<span style="color:Blue;">DISTINCT</span> Title)
<span style="color:Blue;">FROM</span> HumanResources.Employee;
GO

<span style="color:Blue;">USE</span> AdventureWorks;
GO
<span style="color:Blue;">SELECT</span> <span style="color:Magenta;">COUNT</span>(*)
<span style="color:Blue;">FROM</span> HumanResources.Employee;
GO

<span style="color:Blue;">USE</span> AdventureWorks;
GO
<span style="color:Blue;">SELECT</span> <span style="color:Magenta;">COUNT</span>(*), <span style="color:Magenta;">AVG</span>(Bonus)
<span style="color:Blue;">FROM</span> Sales.SalesPerson
<span style="color:Blue;">WHERE</span> SalesQuota &gt; 25000;
GO

<span style="color:Blue;">USE</span> AdventureWorks;
GO
<span style="color:Blue;">SELECT</span> <span style="color:Magenta;">COUNT_BIG</span>(<span style="color:Blue;">DISTINCT</span> Title)
<span style="color:Blue;">FROM</span> HumanResources.Employee;
GO

<span style="color:Blue;">USE</span> AdventureWorks;
GO
<span style="color:Blue;">SELECT</span> <span style="color:Magenta;">COUNT_BIG</span>(*)
<span style="color:Blue;">FROM</span> HumanResources.Employee;
GO

<span style="color:Blue;">USE</span> AdventureWorks;
GO
<span style="color:Blue;">SELECT</span> <span style="color:Magenta;">COUNT_BIG</span>(*), <span style="color:Magenta;">AVG</span>(Bonus)
<span style="color:Blue;">FROM</span> Sales.SalesPerson
<span style="color:Blue;">WHERE</span> SalesQuota &gt; 25000;
GO

<span style="color:Blue;">USE</span> AdventureWorks;
GO
<span style="color:Blue;">SELECT</span> Color, <span style="color:Magenta;">SUM</span>(ListPrice), <span style="color:Magenta;">SUM</span>(StandardCost)
<span style="color:Blue;">FROM</span> Production.Product
<span style="color:Blue;">WHERE</span> Color <span style="color:Blue;">IS</span> <span style="color:Blue;">NOT</span> <span style="color:Blue;">NULL</span> <span style="color:Blue;">AND</span> ListPrice != 0.00 <span style="color:Blue;">AND</span> StyleName <span style="color:Blue;">LIKE</span> <span style="color:#A31515;">'Mountain%'</span>
<span style="color:Blue;">GROUP</span> <span style="color:Blue;">BY</span> Color
<span style="color:Blue;">ORDER</span> <span style="color:Blue;">BY</span> Color;
GO

<span style="color:Blue;">USE</span> AdventureWorks;
GO
<span style="color:Blue;">SELECT</span> Color, ListPrice, StandardCost
<span style="color:Blue;">FROM</span> Production.Product
<span style="color:Blue;">WHERE</span> Color <span style="color:Blue;">IS</span> <span style="color:Blue;">NOT</span> <span style="color:Blue;">NULL</span> <span style="color:Blue;">AND</span> ListPrice != 0.00 <span style="color:Blue;">AND</span> StyleName <span style="color:Blue;">LIKE</span> <span style="color:#A31515;">'Mountain%'</span>
<span style="color:Blue;">ORDER</span> <span style="color:Blue;">BY</span> Color
<span style="color:Blue;">COMPUTE</span> <span style="color:Magenta;">SUM</span>(ListPrice), <span style="color:Magenta;">SUM</span>(StandardCost) <span style="color:Blue;">BY</span> Color;
GO

<span style="color:Blue;">USE</span> AdventureWorks;
GO
<span style="color:Blue;">SELECT</span> Color, <span style="color:Magenta;">SUM</span>(ListPrice), <span style="color:Magenta;">SUM</span>(StandardCost)
<span style="color:Blue;">FROM</span> Production.Product
<span style="color:Blue;">GROUP</span> <span style="color:Blue;">BY</span> Color
<span style="color:Blue;">ORDER</span> <span style="color:Blue;">BY</span> Color
GO

<span style="color:Blue;">USE</span> AdventureWorks;
GO
<span style="color:Blue;">SELECT</span> SalesQuota, <span style="color:Magenta;">SUM</span>(SalesYTD) <span style="color:#A31515;">'TotalSalesYTD'</span>, <span style="color:Magenta;">GROUPING</span>(SalesQuota) <span style="color:Blue;">AS</span> <span style="color:#A31515;">'Grouping'</span>
<span style="color:Blue;">FROM</span> Sales.SalesPerson
<span style="color:Blue;">GROUP</span> <span style="color:Blue;">BY</span> SalesQuota <span style="color:Blue;">WITH</span> <span style="color:Blue;">ROLLUP</span>;
GO

<span style="color:Blue;">USE</span> AdventureWorks;
GO
<span style="color:Blue;">SELECT</span> <span style="color:Magenta;">STDEV</span>(Bonus)
<span style="color:Blue;">FROM</span> Sales.SalesPerson;
GO

<span style="color:Blue;">USE</span> AdventureWorks;
GO
<span style="color:Blue;">SELECT</span> <span style="color:Magenta;">STDEVP</span>(Bonus)
<span style="color:Blue;">FROM</span> Sales.SalesPerson;
GO

<span style="color:Blue;">USE</span> AdventureWorks;
GO
<span style="color:Blue;">SELECT</span> <span style="color:Magenta;">VAR</span>(Bonus)
<span style="color:Blue;">FROM</span> Sales.SalesPerson;
GO

<span style="color:Blue;">USE</span> AdventureWorks;
GO
<span style="color:Blue;">SELECT</span> <span style="color:Magenta;">VARP</span>(Bonus)
<span style="color:Blue;">FROM</span> Sales.SalesPerson;
GO

<span style="color:Blue;">SELECT</span> TitleID, <span style="color:Magenta;">BINARY_CHECKSUM</span>(*) 
<span style="color:Blue;">FROM</span> Pubs.dbo.titles GO <span style="color:Blue;">SELECT</span> EmployeeID, <span style="color:Magenta;">BINARY_CHECKSUM</span>(*) 
<span style="color:Blue;">FROM</span> AdventureWorks.HumanResources.Employee;
GO

<span style="color:Blue;">SELECT</span> <span style="color:Blue;">absolute</span>(10)
</pre></div>